#define _CRT_SECURE_NO_WARNINGS

#include "queue.h"

void InitQueue(SeqQueue* Q)
{
	Q->front = Q->rear = 0;
}

int EnterQueue(SeqQueue* Q, QueueElementType x)
{
	if ((Q->rear + 1) % MAXSIZE == Q->front)
		return (FALSE);
	Q->element[Q->rear] = x;
	Q->rear = (Q->rear + 1) % MAXSIZE;
	return(TRUE);
}

int IsEmpty(SeqQueue* Q)
{
	if ((Q->rear) % MAXSIZE == Q->front)
		return (TRUE);
	return(FALSE);
}

int DeleQueue(SeqQueue* Q, QueueElementType* x)
{
	if (Q->front == Q->rear)
		return (FALSE);
	*x = Q->element[Q->front];
	Q->front = (Q->front + 1) % MAXSIZE;
	return (TRUE);
}